Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use starknet-sierra-compile executable in util #16

Closed

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Apr 1, 2024

This change is Reviewable

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 82.60870% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 59.18%. Comparing base (4a0e789) to head (b225599).

Files Patch % Lines
crates/gateway/src/compiler/compile.rs 82.60% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #16       +/-   ##
===========================================
+ Coverage   38.46%   59.18%   +20.72%     
===========================================
  Files           2        3        +1     
  Lines          26       49       +23     
  Branches       26       49       +23     
===========================================
+ Hits           10       29       +19     
- Misses         14       16        +2     
- Partials        2        4        +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@giladchase giladchase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 6 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware, @dafnamatsry, and @elintul)


crates/gateway/src/compiler/starknet-sierra-compile line 0 at r1 (raw file):
This might have some issues
a) Will this work in non-debian systems?
b) This isn't linked to a specific version of the compiler, otherwise we/users won't know what version of compiler it's using. but that I guess can be fixed by declaring it the file name.
c) lib size will increase by 9 MB, is that ok?
d) Serde has recently tried to pre-compile some of their stuff in crates.io, and the community didn't like it, so they reverted it.
I recommend checking that out and seeing what were the objections.
(For us it broke the Pyo3 build, for example).

@ArniStarkware
Copy link
Contributor Author

crates/gateway/src/compiler/starknet-sierra-compile line 0 at r1 (raw file):
We added the executable starknet-sierra-compile in the path: crates/gateway/src/compiler/starknet-sierra-compile.
To obtain the file I checked out the cario repo (origin/dev-v2.4.3) run: cargo build --release --bin starknet-sierra-compile and took the file from target/release/.

Copy link
Collaborator

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 6 files reviewed, 5 unresolved discussions (waiting on @ArniStarkware and @elintul)


crates/gateway/src/compiler/compile.rs line 11 at r1 (raw file):

// TODO(Arni, 1/05/2024): Add the configurable parameters to the function.
pub fn compile_sierra_to_casm(sierra_path: &str) -> Vec<u8> {
    let add_pythonic_hints = true; // TODO: make this configurable?

Is it configurable now? If not, then let not make it configurable here as well, and you can remove this boolean.


crates/gateway/src/compiler/compile.rs line 14 at r1 (raw file):

    let compiler_path = STARKNET_SIERRA_COMPILE_EXE;

    let mut command = Command::new(compiler_path);

We should be able to limit the resources usage of the compiler (like memory usage).


crates/gateway/src/compiler/compile.rs line 15 at r1 (raw file):

    let mut command = Command::new(compiler_path);
    command.arg(sierra_path);

In Python, I see that we run the compiler with additional args like --max-bytecode-size, --allowed-libfuncs-list-name, --allowed-libfuncs-list-file.


crates/gateway/src/compiler/compile.rs line 29 at r1 (raw file):

    let stderr_output = String::from_utf8(compile_output.stderr).unwrap(); // TODO: handle error
    if !compile_output.status.success() {
        panic!("Failed to compile Sierra code: {}", stderr_output);

Please return an error.

@ArniStarkware ArniStarkware deleted the arni/sierra_to_casm/use_executable/skelaton branch May 30, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants